﻿@using PagedList
@using PagedList.Mvc
@model NapCardOnline.ViewModel.HistoryViewModels

@{
    ViewBag.Title = "Lịch sử giao dịch";
}
<h2>@ViewBag.Title</h2>
<div class="tabbable">
    <!-- Only required for left/right tabs -->
    <ul class="nav nav-tabs">
        <li id="tab-payment" class="active"><a href="#tab1">Thanh toan</a></li>
        <li id="tab-recharge"><a href="#tab2">Gui tien</a></li>
        <li id="tab-transfer"><a href="#tab3">Chuyen tien</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab1">
            <div class="tab-pane active" id="tab3">
                <table class="table table-bordered">
            <thead>
                <tr>
                <th>
                    Mã GD
                </th>
                <th>
                    Dịch vụ
                </th>
                <th>
                    TK nhận
                </th>
                <th>
                    Ngày giờ giao dịch
                </th>
                <th>
                    Nội dung
                </th>
                <th>
                    Số tiền
                </th>
                <th>
                    Tiền CK
                </th>
                <th>
                    Trạng thái
                </th>
            </tr> 
            </thead>
            <tbody>
                     @foreach (var item in Model.TransferFundList)
                     {
                         <tr>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundNo)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundType.TransferFundTypeName)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.User1.UserName)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundDate)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundDesc)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundAmount)
                             </td>
                             <td>
                                 @Html.DisplayFor(modelItem => item.TransferFundCommissionAmount)
                             </td>
                             <td>
                                 @switch (item.FK_StatusID)
                                 {
                                     case 1:
                                         <span class="label label-success">
                                             @Html.DisplayFor(modelItem => item.Status.StatusName)
                                         </span>
                                         break;
                                     case 2:
                                         <span class="label label-important">
                                             @Html.DisplayFor(modelItem => item.Status.StatusName)
                                         </span>
                                         break;
                                     case 3:
                                         <span class="label label-warning">
                                             @Html.DisplayFor(modelItem => item.Status.StatusName)
                                         </span>
                                         break;
                                 }
                             </td>
                         </tr>
                     }
            </tbody>
            <tfoot>
                <tr>
                    <th colspan="4" style="text-align: center;">Có tất cả @(ViewBag.CountTransfer) giao dịch</th>
                    <th style="text-align: center;">Tổng cộng</th>
                    <th>@ViewBag.TotalAmount</th>
                    <th>@ViewBag.TotalCommisionAmount</th>
                    <th></th>
                </tr>
            </tfoot>
        </table>
            </div>
        </div>
        <div class="tab-pane" id="tab2">
            <p>
                Gửi tiền</p>
        </div>
        <div class="tab-pane" id="tab3">
            Chuyen tien
        </div>
    </div>
</div>
@*@Html.PagedListPager((IPagedList)ViewBag.OnePageOfTransferFund, page => Url.Action("LoadTransferFund", new { page }))*@
<script language="javascript" type="text/javascript">
    $(function () {

        $("#tab-payment a").click(function (e) {
            e.preventDefault();
           // $(this).load('@Url.Action("Index", "Payment")');
            
            $.ajax({
                  url: '@Url.Action("LoadTransferFund", "History")', 
                  data:JSON.stringify(1),
                   type: 'POST',
                   contentType:'application/json; charset=utf-8',
                   dataType:'json',
                   success:function (data) {
                       $(".table table-bordered").append(data.success);
                  },
                  error:function () {
                      alert('Loi');
                  },
            });
             $(this).tab('show');
            
        });
        

        $("#tab-recharge a").click(function (e) {
            e.preventDefault();
            $(this).load('@Url.Action("Index", "Recharge")');
            $(this).tab('show');
            
        });

        $("#tab-transfer a").click(function (e) {
            e.preventDefault();
            $(this).tab('show');
        });
    });
</script>
